<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //const声明一个只读的常量。一旦声明，常量的值就不能改变。
        const PI = 3.1415;
        PI = 3;// TypeError: Assignment to constant variable.
        
        //const一旦声明变量，就必须立即初始化，不能留到以后赋值。
        const foo;//'const' declarations must be initialized.

        //const的作用域与let命令相同：只在声明所在的块级作用域内有效。
        if (true) {
            const MAX = 5;
        }

        console.log(MAX) // Uncaught ReferenceError: MAX is not defined
    </script>
</body>
</html>